Repository navigation
test(gapic-generator): add Showcase operational error logging compliance suite - #19141
chalmerlowe wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive system test suite for operational error logging compliance (F4 & F5) against a live Showcase server, alongside normalizing the rpc.method attribute in google-api-core's observability module to ensure leading slashes are stripped and edge cases are handled correctly. The review feedback highlights an improvement opportunity in the test harness to avoid multiplying lists of mutable protobuf messages, which creates shared references, and suggests using list comprehensions instead to ensure independent instances.
| responses = [ | ||
| Sequence.Response( | ||
| status=status_pb2.Status( | ||
| code=code_pb2.UNAVAILABLE, | ||
| message="Persistent outage", | ||
| ) | ||
| ) | ||
| ] * EXHAUSTED_RETRY_ATTEMPTS |
There was a problem hiding this comment.
Multiplying a list containing a mutable protobuf message object (e.g., [Sequence.Response(...)] * N) creates a list of references to the exact same object. If any part of the test or client code mutates one of these responses, all elements in the list will be affected, which can lead to subtle bugs or flaky tests. Using a list comprehension ensures that a distinct, independent instance is created for each element.
| responses = [ | |
| Sequence.Response( | |
| status=status_pb2.Status( | |
| code=code_pb2.UNAVAILABLE, | |
| message="Persistent outage", | |
| ) | |
| ) | |
| ] * EXHAUSTED_RETRY_ATTEMPTS | |
| responses = [ | |
| Sequence.Response( | |
| status=status_pb2.Status( | |
| code=code_pb2.UNAVAILABLE, | |
| message="Persistent outage", | |
| ) | |
| ) | |
| for _ in range(EXHAUSTED_RETRY_ATTEMPTS) | |
| ] |
| responses = [ | ||
| Sequence.Response( | ||
| status=status_pb2.Status( | ||
| code=code_pb2.UNAVAILABLE, | ||
| message="Temporary glitch", | ||
| ) | ||
| ) | ||
| ] * recovery_failed_attempts + [ | ||
| Sequence.Response(status=status_pb2.Status(code=code_pb2.OK)) | ||
| ] |
There was a problem hiding this comment.
Multiplying a list containing a mutable protobuf message object (e.g., [Sequence.Response(...)] * N) creates a list of references to the exact same object. If any part of the test or client code mutates one of these responses, all elements in the list will be affected, which can lead to subtle bugs or flaky tests. Using a list comprehension ensures that a distinct, independent instance is created for each element.
responses = [
Sequence.Response(
status=status_pb2.Status(
code=code_pb2.UNAVAILABLE,
message="Temporary glitch",
)
)
for _ in range(recovery_failed_attempts)
] + [
Sequence.Response(status=status_pb2.Status(code=code_pb2.OK))
]7f09887 to
00492f5
Compare
00492f5 to
bb492a4
Compare
591ef2b to
facba85
Compare
bb492a4 to
8d664f4
Compare
facba85 to
210b44b
Compare
8d664f4 to
30e2042
Compare
210b44b to
b233ccb
Compare
30e2042 to
afea252
Compare
b233ccb to
49970f9
Compare
afea252 to
cd009e1
Compare
71f503f to
fd3ad4c
Compare
cd009e1 to
419bf2d
Compare
fd3ad4c to
c45a48b
Compare
419bf2d to
28f2bb8
Compare
…nce suite Add the 28-row operational error logging matrix (F4.1-F5.14), Showcase compliance harness, sync/async compliance tests, and CI raw_logs_output.json artifact upload. Bug: b/479827845
…s, and authentic tracebacks - Appends explicit trailing '*' wildcards to active F5 Message Prefix cells and validates log messages with exact equality unless '*' is present. - Asserts active-trace logs fall within target span start/end timestamps. - Rejects synthetic _build_attempt_log_extra / build_telemetry_error_attributes frames in <TRACEBACK> assertions.
28f2bb8 to
5b50f2d
Compare
c45a48b to
b47d72d
Compare
Problem / Context
Operational error logging (
F4wire-attemptDEBUGlogs andF5client-methodWARNINGlogs) needs end-to-end verification against a live GAPIC Showcase server across synchronous and asynchronous gRPC and HTTP/REST transports, matching the declarative matrix approach used for OpenTelemetry tracing compliance (test_span_compliance.py).Bug: b/479827845
Solution
packages/gapic-generator/tests/system/showcase_harness.py):load_csv_matrix), sync/async Showcase client construction (construct_showcase_client),google.rpc.ErrorInfostatus construction, deterministic Echo/Sequence scenario execution (execute_showcase_scenario,execute_showcase_scenario_async), async gRPC inspection task draining, andInMemoryLogCapture.packages/gapic-generator/tests/system/):logging_requirements_matrix.csv(28 atomic rows coveringF4.1–F5.14across HTTP/REST and gRPC with explicit sync/async expectations where transport exception types differ, canonicalgoogle.rpc.Codestatus strings on L3 and gRPC L4, omittedrpc.response.status_codeon HTTP L4, omittedhttpRequest.statuson client timeouts, exactstatus.messageparity, explicit*...*wildcards for non-exactexception.messageassertions, and<TRACEBACK>multi-frame checks across all exception-bearing rows).test_logging_compliance.pyvalidating both rawlogging.LogRecordattributes andStructuredLogFormatterJSON output across all 56 sync + async scenarios (grpc,grpc_asyncio,rest, andrest_asyncio), including disabled-flag suppression on failing RPCs, happy-path silence, retry recovery suppression, L4DEBUGwire attempts, L3WARNINGterminal failures, activeT3/T4OpenTelemetry span correlation,ErrorInfofallback boundaries, and companion active-trace span export (raw_logging_spans_output.json) alongsideraw_logs_output.json..github/workflows/gapic-generator-tests.yml):SHOWCASE_RAW_LOGS_OUTPUT_PATHand uploadsraw_logs_output.jsonand companionraw_logging_spans_output.jsoninshowcaseandshowcase-canaryjobs alongsideraw_spans_output.json, while keeping local test runs hermetic viatmp_path_factory.Notes for Reviewers
feat/otel-logging-rest-asyncio(feat(gapic-generator): wire async REST total_attempts and async trace response recording #19154, which itself stacks on fix(api_core): normalize observability log attributes and canonical status codes #19144) so this PR stays scoped strictly topackages/gapic-generator/tests/system/and its CI workflow.test_logging_compliance.pyandtest_span_compliance.pywrap strict monorepo assertions inconftest.skip_on_core_mismatch()so standardshowcasejobs running against PyPIgoogle-api-coredo not break before release, whileshowcase-canary(INSTALL_LOCAL_CORE=true) enforces all assertions.rest_async_io_enabled, the 14rest_asynciocases auto-skip cleanly while all 28 sync and 14grpc_asynciocases execute; inshowcase_w_rest_async, all 56 sync + async matrix cases execute.Verification
packages/gapic-generatorlocally against live GAPIC Showcase (v0.44.2) in Docker across:showcase_w_rest_async-3.14(INSTALL_LOCAL_CORE=true)showcase-3.10(INSTALL_LOCAL_CORE=true)showcase-3.14against released PyPIgoogle-api-core(non-canary compatibility check)